/**
 * This file is part of the CAKIS project.
 * 
 * Copyright (c) 2009-2010 - Florian Arndt, Christian Kerl
 * 
 * @license GNU Lesser General Public License v3 <http://www.opensource.org/licenses/lgpl-3.0.html>
 * @since   01.03.2010
 * @version SVN: $Id: StockItemHome.java 118 2010-05-09 20:27:05Z christian-kerl@web.de $
 */

package org.cakis.server.action.impl;

import org.cakis.server.model.StockItem;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.web.RequestParameter;
import org.jboss.seam.framework.EntityHome;

@Name("stockItemHome")
public class StockItemHome extends EntityHome<StockItem>
{
    private static final long serialVersionUID = 1L;

    @RequestParameter Long stockItemId;

    @Override
    public Object getId()
    {
        if (stockItemId == null)
        {
            return super.getId();
        }
        else
        {
            return stockItemId;
        }
    }

    @Override @Begin
    public void create() {
        super.create();
    }

    @Override
    public String persist() {
        instance.setQuantity(instance.getProduct().getStandardQuantity());

        return super.persist();
    }
}
